﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="importwz.aspx.cs" Inherits="weba.importwz" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css">
        html {
            height: 100%;
        }

        body {
            height: 100%;
            margin: 0px;
            padding: 0px;
        }

        #container {
            height: 450px;
            width: 800px;
            float: left;
        }

        #form1 {
            width: 800px;
            height: 300px;
            float: left;
        }

        #ztd {
            height: auto;
            width: 150px;
            float: left;
        }
    </style>
    <script type="text/javascript"
        src="http://webapi.amap.com/maps?v=1.2&key=ab5ae8097e26040fa604012b73e78f03">
    </script>
    <script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        var mapObj;
        var ln;
        var point
        function ab() {
            mapObj.clearMap();
        }
        function a() {
            var jingdu = new Array();
            var weidu = new Array();
            // alert("result");
            //  weba.wajax.HelloWorld(onresult);
            $(":checkbox").each(function () {
                if ($(this).prop("checked")) {
                    var jx = $(this).parent().parent().children("td:eq(4)").html()
                    var jy = $(this).parent().parent().children("td:eq(5)").html()
                    jingdu.push(jx)
                    weidu.push(jy)
                    // alert(jx)
                }
            })
            //   alert(v)}
            for (var i = 0; i < jingdu.length; i++) {
                var markerac = new AMap.Marker({
                    id: "i",
                    position: new AMap.LngLat(jingdu[i], weidu[i]),
                    icon: "http://webapi.amap.com/static/images/marker_sprite.png",
                    offset: { x: -8, y: -34 }
                });// 创建点坐标
                mapObj.addOverlays(markerac);
            }
        }
        function onresult(result) {
            alert(result);
        }
        function initialize() {

            mapObj = new AMap.Map("container"); // 创建地图实例
            if (ln == null) {
                point = new AMap.LngLat(121.550331, 29.868038); // 创建点坐标
            }
            else {
                point = new AMap.LngLat(ln.getLng(), ln.getLat()); // 创建点坐标
            }
            // var point = new AMap.LngLat(116.404, 39.915); // 创建点坐标
            mapObj.setCenter(point); // 设置地图中心点坐标

            mapObj.bind(mapObj, "click", function (e) {
                ln = e.lnglat;
                var marker = new AMap.Marker({
                    id: "m123",
                    position: e.lnglat,
                    icon: "http://webapi.amap.com/static/images/marker_sprite.png",
                    offset: { x: -8, y: -34 }
                });
                //  alert(ln.getLng());
                mapObj.addOverlays(marker);
                mapObj.setCenter(ln);

            });
        }
        function raa() {
          //  alert(mapObj);
            var jingdu = new Array();
            var weidu = new Array();
        <%  
        foreach (DictionaryEntry ha in ht)
        {
          %>
            // x=   WebService.HelloWorld();
            //  alert("adda");
            //  x = ln.getLng();
            //  var y = ln.getlnt();
            jingdu.push(<%=ha.Key.ToString()%>);
            weidu.push(<%= ha.Value.ToString()%>);
        
        <%   
        }  
  %>
           // alert(jingdu.length)
         //   for (var i = 0; i < jingdu.length; i++) {
                var markerac = new AMap.Marker({
                    id: "i",
                    position: new AMap.LngLat(jingdu[0], weidu[0]),
                    icon: "http://webapi.amap.com/static/images/marker_sprite.png",
                    offset: { x: -8, y: -34 }
                });// 创建点坐标
              //  mapObj.addOverlays(markerac);
          //  }
           
        }
    </script>


</head>
<body onload="initialize()">
    <form id="form1" runat="server" title="批量导入位置">
        <div>

            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="id">
                <Columns>
                    <asp:TemplateField>
                        <EditItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
                    <asp:BoundField DataField="firstName" HeaderText="firstName" SortExpression="firstName" />
                    <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
                    <asp:BoundField DataField="lx" HeaderText="lx" SortExpression="lx" />
                    <asp:BoundField DataField="ly" HeaderText="ly" SortExpression="ly" />
                    <asp:BoundField DataField="city" HeaderText="city" SortExpression="city" />
                </Columns>
            </asp:GridView>
            <asp:Label ID="Label2" runat="server" Text="选择过滤条件"></asp:Label>
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
                <asp:ListItem Selected="True" Value="0">请选择区</asp:ListItem>
                <asp:ListItem Value="1">海曙区</asp:ListItem>
                <asp:ListItem Value="2">江北区</asp:ListItem>
                <asp:ListItem Value="3">江东区</asp:ListItem>
                <asp:ListItem Value="4">鄞州区</asp:ListItem>
            </asp:DropDownList>
            <br/>
             <input id="Button2" type="button" value="批量导入位置" onClick="a()" title="批量导入位置"  />
         <input id="Button3" type="button" value="清空" onClick="ab()" title="清空"  />
            <asp:Button ID="bt1" runat="server" OnClick="Button1_Click" Width="80px" Text="位置总数" />
            <asp:Label ID="Label1" runat="server" Text="共：（）个"></asp:Label>
            <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="weba.sjklqDataContext" EntityTypeName="" Select="new (id, firstName, title, lx, ly, city, postalCode)" TableName="People" Where="postalCode == @postalCode">
                <WhereParameters>
                    <asp:ControlParameter ControlID="DropDownList1" Name="postalCode" PropertyName="SelectedValue" Type="String" />
                </WhereParameters>
            </asp:LinqDataSource>
            <br />

        </div>

        
    <div id="container"></div>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SmallCompanyDBConnectionString %>" SelectCommand="gl" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" DefaultValue="" Name="pscode" PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>

        
    </form>
    </body>
</html>
